package twelve;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

@MyAnnotation01(age = 19,
        studentName = "老高",
        id = 12,
        schools = {"北京大学", "上海尚学堂"}
)
public class TestAnnotation01 {

    @Override
    public String toString() {
        return "";
    }

    @Deprecated
    public static void save() {

    }

    /**
     * deprecation 过时的类和方法
     * unchecked 使用集合时未指定泛型
     * fallthrough switch语句使用时发生case穿透
     * path 在类路径、源文件路径等中有不存在路径的警告
     * serial 在可序列化的类上缺少serialVersionUID定义时的警告
     * finally 任何finally子句不能完成时的警告
     * all 关于以上所有情况的警告
     */
    @SuppressWarnings("all")
    public static void delete() {
        List list = new ArrayList();
    }

    @MyAnnotation01
    public static void test() {

    }

    public static void main(String[] args) {
        save();
        try {
            Class clazz = Class.forName("twelve.SxtStudent");
            Annotation[] annotations = clazz.getAnnotations();
            for (Annotation annotation : annotations) {
                System.out.println(annotation);
            }

            SxtTable st = (SxtTable) clazz.getAnnotation(SxtTable.class);
            System.out.println(st.value());

            Field f = clazz.getDeclaredField("studentName");
            SxtField sxtField = f.getAnnotation(SxtField.class);
            System.out.println(sxtField.columnName() + "--" + sxtField.type() + "--" + sxtField.length());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
